/* systick_utils.h
 * Utilities to set SysTick period and delay using SysTick ticks.
 */
#ifndef BSP_SYSTICK_UTILS_H
#define BSP_SYSTICK_UTILS_H

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
 * Set SysTick period in milliseconds.
 * @param ms period in milliseconds
 */
void set_systick_ms(uint32_t ms);

/**
 * Delay for a number of SysTick periods.
 * @param ticks number of SysTick ticks to wait
 */
void delay_ticks(uint32_t ticks);

/**
 * Blocking delay for a number of microseconds. Uses cycle busy-wait.
 * @param us microseconds to delay
 * 此函数依赖于ti/driverlib/dl_common.h中的DL_Common_delayCycles实现，
 * 每一us在80MHz时80个cycles。汇编在出入函数时可能会有最大几个cycles的误差。
 * 如需精确延时使用时请注意。用于总线延时问题不大。
 */
void delay_us(uint32_t us);

#ifdef __cplusplus
}
#endif

#endif // BSP_SYSTICK_UTILS_H
